package com.klun.hdfs.hd.driver;

import com.klun.hdfs.hd.mapper.FlowCountMapper;
import com.klun.hdfs.hd.pojo.FlowBean;
import com.klun.hdfs.hd.reducer.FlowCountReducer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import javax.xml.soap.Text;
import java.io.IOException;

public class FlowsumDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        Configuration configuration =new Configuration();
        Job job = Job.getInstance(configuration);

        // 指定本程序的jar包所在的本地路径
        job.setJarByClass(FlowsumDriver.class);

        job.setMapperClass(FlowCountMapper.class);
        job.setReducerClass(FlowCountReducer.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(FlowBean.class);

        // 指定job的输入路径和输出路径
        FileInputFormat.setInputPaths(job,new Path(args[0]));
        FileOutputFormat.setOutputPath(job,new Path(args[1]));

        // job启动并等待
        boolean result = job.waitForCompletion(true);
        System.exit(result?0:1);
    }
}
